package org.dromara.germbank.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.germbank.domain.bo.BusApprovalMaterialsBo;
import org.dromara.germbank.domain.bo.BusPartnerDoctorBo;
import org.dromara.germbank.domain.vo.BusPartnerDoctorVo;
import org.dromara.germbank.service.BusPartnerDoctorService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 医疗团队管理
 *
 * @author congxing
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/doctor")
public class BusPartnerDoctorController extends BaseController {

    private final BusPartnerDoctorService busPartnerDoctorService;

    /**
     * 查询医生团队管理列表
     */

    @GetMapping("/list")
    public TableDataInfo<BusPartnerDoctorVo> list(BusPartnerDoctorBo bo, PageQuery pageQuery) {

        return busPartnerDoctorService.queryPageList(bo,pageQuery);
    }

//    /**
//     * 新增广告
//     */
//    @SaCheckPermission("germbank:advertisement:add")
//    @Log(title = "广告管理", businessType = BusinessType.INSERT)
//    @PostMapping
//    public R<Void> add(@Validated @RequestBody BusPartnerDoctorBo bo) {
//        if (!busPartnerDoctorService.checkDoctorNameUnique(bo)) {
//            return R.fail("新增广告'" + bo.getDoctorName() + "'失败，广告名称已存在");
//        }
//        return toAjax(busPartnerDoctorService.insertDoctor(bo));
//    }


//    /**
//     * 修改保存广告
//     */
//    @SaCheckPermission("germbank:advertisement:edit")
//    @Log(title = "广告数据", businessType = BusinessType.UPDATE)
////    @RepeatSubmit()
//    @PutMapping
//    public R<Void> edit(@Validated @RequestBody BusPartnerDoctorBo bo) {
//        if (!busPartnerDoctorService.checkDoctorNameUnique(bo)) {
//            return R.fail("修改广告数据'" + bo.getDoctorName() + "'失败，广告已存在");
//        }
//        busPartnerDoctorService.updateDoctorData(bo);
//        return R.ok();
//    }


    /**
     * 删除广告类型
     *
     * @param doctorCodes     * 删除广告类型code串
     */
    @SaCheckPermission("germbank:advertisement:remove")
    @Log(title = "广告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{doctorCodes}")
    public R<Void> remove(@PathVariable Long[] doctorCodes) {
        busPartnerDoctorService.deleteDoctorDataByIds(Arrays.asList(doctorCodes));
        return R.ok();
    }
}
